Vue.prototype.$http = axios
// 设置默认前
axios.defaults.baseURL='http://localhost/'

/* 前置拦截器 axios请求后台前拦截 */
axios.interceptors.request.use(config=>{
  //携带token
   let token =  localStorage.getItem("token");
   if(token){
       config.headers['token']=token;
   }
   return config;
},error => {
    Promise.reject(error);
})
/* 显示图片请求头 */
Vue.prototype.$fastdfs = "http://115.159.217.249:8888"

/* axios请求响应拦截 */
axios.interceptors.response.use(result=>{
    let data = result.data;
    if(!data.success && data.message==="noUser"){
        location.href = "/login.html";
		localStorage.removeItem("token");
		localStorage.removeItem("user");
	}
    return result;
},error => {
    Promise.reject(error);
})
/* js获取url中的参数 */
function getQueryVariable(variable)
{
   var query = window.location.search.substring(1);
   var vars = query.split("&");
   for (var i=0;i<vars.length;i++) {
		   var pair = vars[i].split("=");
		   if(pair[0] == variable){return pair[1];}
   }
   return(false);
}